class Solution(object):
    def maximumUniqueSubarray(self, nums):
        n = len(nums)
        left = 0
        right = 0
        a_set = set()
        max_len = 0
        now = 0
        while right < n:
            while nums[right] in a_set:
                a_set.remove(nums[left])
                now -= nums[left]
                left += 1
            a_set.add(nums[right])
            now += nums[right]
            max_len = max(max_len, now)
            right += 1
        return max_len

